package LeiHeiDuiXiang.LeiHeDuiXiang2.LiangXi1.Test;

import java.util.Arrays;
import java.util.Date;

class Student{
    //字段 属性 成员变量：定义在类当中，方法的外边
    public String name;
    private int age;
    private String stuNum;//学号

    public  static String className;//班级

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getStuNum() {
        return stuNum;
    }

    public void setStuNum(String stuNum) {
        this.stuNum = stuNum;
    }


    public Student(String name ,int age,String stuNum){
        this.name=name;
        this.age=age;
        this.stuNum=stuNum;
        System.out.println("调用了三个带参数的构造方法");
    }

    public Student(){
        System.out.println("不带参数的构造方法....");
        //this("zhangsan",10,"123");
    }

    //成员方法
    public void eat(){
        System.out.println(this.name+"正在吃饭！");
    }

    public void doClass(){
        func();
        System.out.println(this.name+"正在上课");
    }

    private  void func(){
        //其他的业务操作
        System.out.println("这个方法就是为奔雷其他访问服务的不对外公开");
    }

    public void show(){
        System.out.println("姓名:"+this.name+"年龄:"+this.age+
                "学号："+this.stuNum+"班级"+className);
    }
}

public class Test {
    public static void main1(String[] args) {
        Student.className="1班";
        Student student1=new Student();
        //Student student1=null;
        //student1.className="1班";
        System.out.println(student1.name);
    }

    public static void main2(String[] args) {
        Student student2=new Student("zhangsan",10,"1235");
        //student2.className="1班";
        //通过类名访问更推荐,也可以通过对象访问
        Student.className="1班";
        student2.show();
        Student student3=new Student("lisi",19,"1222");
        student3.show();
    }

    public static void main(String[] args) {
        int[] array={1,2,3,4,5};
        System.out.println(Arrays.toString(array));
        Date date=new Date();

        //Arrays

        java.sql.Date date1=new java.sql.Date(10000);

        System.out.println(date1);
    }

    public static void main4(String[] args) {
        double x=30;
        double y=40;
        //静态导入的方式写起来更方便一点。
        double result=Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
        System.out.println(result);
    }

    public static void main5(String[] args) {
        Student student51=new Student("zhangsan",10,"1024");

        Student student52=new Student();

        //student6.name="lisi";

        student52.setName("zhangsan");
        System.out.println(student52.getName());
        student52.setAge(10);
        System.out.println(student52.getAge());
        student52.setStuNum("12345");
        System.out.println(student52.getStuNum());
    }

    public static void main6(String[] args) {
        //对象的实例化
        Student student61=new Student();
        student61.name="zhangsan";
        student61.setAge(10);
        student61.setStuNum("1223");
        System.out.println(student61.name);
        System.out.println(student61.getAge());
        System.out.println(student61.getStuNum());
        student61.doClass();
        student61.eat();
        System.out.println("=========");
        Student student62=new Student();
        student62.name="lisi";
        student62.setAge(12);
        student62.setStuNum("20240312");
        System.out.println(student62.name);
        System.out.println(student62.getAge());
        System.out.println(student62.getStuNum());
        student62.doClass();
        student62.eat();
    }
}
